package router

import (
	"cec-server/app/api"
	"cec-server/app/api/web/controller"
	_ "cec-server/docs"
	"github.com/gin-gonic/gin"
	swaggerFiles "github.com/swaggo/files"
	ginSwagger "github.com/swaggo/gin-swagger"
)

func Router() *gin.Engine {
	r := gin.Default()

	user := r.Group("/user")
	user.GET("/list/:id/:name", api.User{}.List)
	user.PUT("/add", api.User{}.Add)
	user.DELETE("/delete", api.User{}.Delete)
	user.POST("/insert", api.User{}.Insert)

	book := r.Group("book")
	book.GET("/list", api.Book{}.List)
	book.PUT("/add", api.Book{}.Add)
	book.GET("/delete", api.Book{}.Delete)

	message := r.Group("/message")
	message.POST("/send", controller.Message{}.SendMessage)

	// 添加Swagger路由
	r.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler))

	return r
}
